using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;

public class UIButtonPanelPhaser : MonoBehaviour 
{
    public string mCurrentPanelName;
    public string mDestinationPanelName;

    private GameObject RootRef;
    private List<GameObject> mPanelList;
    // Use this for initialization
    void Start()
    {
        mPanelList = new List<GameObject>();
        GetPanelList();
    }

    void GetPanelList()
    {
        // Fill the list with all the panels in the scene. 
        // This is a pretty unfortunate way to iterate through our gigantic heirarchy made by NGUI -.-
        foreach (Transform camera in GameObject.Find("UI Root (2D)").transform)
            if (camera.name == "Camera")
                foreach (Transform anchor in camera.transform)
                    if (anchor.name == "Anchor")
                        foreach (Transform uiPanel in anchor.transform)
                            mPanelList.Add(uiPanel.gameObject);
    }

    GameObject GetPanelNamed(string panelName)
    {
        GameObject retPanel = new GameObject();
        foreach (GameObject uiPanel in mPanelList)
            if (uiPanel.name == panelName)
                retPanel = uiPanel;

        if(retPanel.name != panelName)
            throw new Exception("Could not find the specified panel. Please make sure the panel you are looking for has the same name as the value passed in.");
        else
            return retPanel;
    }
    // Update is called once per frame
    void Update () 
    { }

    void OnClick()
    {
        NGUITools.SetActive(GetPanelNamed("MainMenu"), false);
        NGUITools.SetActive(GetPanelNamed("SoundSettingsMenu"), true);
    }
}
